<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
    <title>新增银行理财信息</title>
    <link href="css/bootstrap.css/bootstrap.min.css" rel="stylesheet">
    <script src="js/bootstrap.js/bootstrap.min.js"></script>
    <script src="jquery/jquery-3.4.1.min.js"></script>
</head>
<body>
<div class="container">
    <h1 class="text-center">新增银行理财信息</h1>
    <form action="addd" method="post" style="width: 300px" class="center-block">
        <div class="form-group">
            <label>产品代码</label>
            <input type="text" class="form-control" name="id" id="id">
        </div>
        <div class="form-group">
            <label>风险评级</label>
            <select name="risk" id="risk" class="form-control">
                <option value="0">请选择</option>
                <option value="1">R1</option>
                <option value="2">R2</option>
                <option value="3">R3</option>
            </select>
        </div>
        <div class="form-group">
            <label>预期收益</label>
            <input type="text" class="form-control"  name="income" id="income">
        </div>
        <div class="form-group">
            <label>发售起始日</label>
            <input type="text" class="form-control"  name="saleStarting" id="saleStarting">
        </div>
        <div class="form-group">
            <label>发售截止日</label>
            <input type="text" class="form-control"  name="saleEnd" id="saleEnd">
        </div>
        <div class="form-group">
            <label>产品到期日</label>
            <input type="text" class="form-control"  name="end" id="end">
        </div>
        <div class="form-group">
            <input type="submit" class="btn btn-primary"  value="提交" id="sub">
            <input type="reset" class="btn btn-primary" value="重置" id="bu"> <a href="show" class="btn btn-primary">返回</a>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        form();
        function form(){
            $(".center-block").bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    id: {
                        message: 'The username is not valid',
                        validators: {
                            notEmpty: {
                                message: '产品代码不能为空'
                            },
                            digits: {
                                message: '该值只能包含数字。'
                            },
                            stringLength: {
                                min:6,
                                max:6,
                                message: '长度必须6位'
                            }
                        }
                    },
                    risk: {
                        message: 'The username is not valid',
                        validators: {
                            notEmpty: {
                                message: '风险等级不能为空'
                            },
                            callback: {
                                message: '必须选择一个风险等级',
                                callback: function (value, validator) {
                                    if (value == 0) {
                                        return false;
                                    }else {
                                        return true;
                                    }
                                }
                            }
                        }
                    },
                    income: {
                        message: 'The username is not valid',
                        validators: {
                            notEmpty: {
                                message: '风险等级不能为空'
                            },
                            regexp: {
                                regexp: /^[4-6][.]\d{1,2}%/,
                                message: '利率格式为4-7%之间（%必须写，小数点后最多保留2位小数）'
                            }
                        }
                    },
                    saleStarting: {
                        validators: {
                            notEmpty: {
                                message: '时间不能为空'
                            },
                            regexp: {
                                regexp:/((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)/,
                                message: '日期必须为yyyy-MM-dd格式'
                            }
                        }
                    },
                    saleEnd: {
                        validators: {
                            notEmpty: {
                                message: '时间不能为空'
                            },
                            regexp: {
                                regexp:/((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)/,
                                message: '日期必须为yyyy-MM-dd格式'
                            }
                        }
                    },
                    end: {
                        validators: {
                            notEmpty: {
                                message: '时间不能为空'
                            },
                            regexp: {
                                regexp:/((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)/,
                                message: '日期必须为yyyy-MM-dd格式'
                            }
                        }
                    }
                }
            });
        }

        $("#bu").click(function () {
            $(".form-control").val("");
            $('.center-block').bootstrapValidator('resetForm', true);
            form();
        })
    });
</script>
<script type="text/javascript" src="js/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</body>
</html>